package com.china08.yxyapi.api.manage.sch.office2.inner;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.repository.mg.YxyNoticeInnerRepository;

@CrossOrigin
@RestController
public class SchOfficeInnerNoReadCountController extends YxyApiBaseController {

    @Autowired
    YxyNoticeInnerRepository yxyNoticeInnerRepository;

    @RequestMapping(value = "/api_yw/manage/sch/office/inner/noReadCount", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Object precess(HttpServletRequest request, HttpServletResponse response) {
        String schoolId = getProfile(request, response).getSchoolId();
        String currentUserId = getProfile(request, response).getId();
        Integer count = yxyNoticeInnerRepository.SchoolIdAndReceiverUserIdAndReceiverIsDeleteAndReceiverIsRead(schoolId, currentUserId, 0, 0);
        RespModel respModel = new RespModel();
        respModel.count = count;
        return respModel;
    }

    public static class RespModel extends YxyApiRespModel {
        public int count = 0;
    }
}
